package com.x.xiaoshuo.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.x.mvp.widget.dateselector.dialog.BaseDialog;
import com.x.xiaoshuo.R;


public class ChapterDialog extends BaseDialog {
    private View dialogView;
    private TextView all;
    private TextView fromNow;
    private TextView cannel;

    private View.OnClickListener onClickListener;

    public ChapterDialog(Context mContext) {
        this.context = mContext;
        create();
    }

    private void create() {
        if (dialog != null) {
            return;
        }
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        dialogView = layoutInflater.inflate(R.layout.dialog_download, null);
        all = (TextView) dialogView.findViewById(R.id.all);
        fromNow = (TextView) dialogView.findViewById(R.id.fromNow);
        cannel = (TextView) dialogView.findViewById(R.id.cannel);

        all.setOnClickListener(onClickListener);
        cannel.setOnClickListener(onClickListener);
        fromNow.setOnClickListener(onClickListener);
        dialog = new Dialog(context, com.x.mvp.R.style.quick_dialog);
        initDialog();
        dialog.setContentView(dialogView);
    }

    public void setOnClickListener(View.OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
        if (all != null) {
            all.setOnClickListener(onClickListener);
            cannel.setOnClickListener(onClickListener);
            fromNow.setOnClickListener(onClickListener);
        }
    }

    public void show(int max, int min) {
        if (dialog == null || dialog.isShowing()) {
            return;
        }
        dialog.show();
    }


}
